package com.hqyj.javaGraduation.hotel.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hqyj.javaGraduation.hotel.account.pojo.AccountUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

@Mapper
public interface HotelMemberMapper extends BaseMapper<AccountUser> {

    /**
     * 查看会员列表
     * 同时可以查看其他角色列表
     */
    String sql = "SELECT u.* FROM account_user u LEFT JOIN account_user_role ur ON u.user_id = ur.user_id" +
            " LEFT JOIN account_role r ON ur.role_id = r.role_id " +
            "WHERE r.role_name = #{map1.role_name}";
    @Select(sql)
    IPage<AccountUser> getMember(IPage<AccountUser> page, @Param("map1") Map map1);

    /**
     * 查看会员列表不同等级的会员
     * @param page
     * @param map2
     * @return
     */
    @Select("SELECT u.* FROM account_user u LEFT JOIN account_user_role ur ON u.user_id = ur.user_id" +
            " LEFT JOIN account_role r ON ur.role_id = r.role_id" +
            " WHERE r.role_name = 'member' and u.user_member = #{map2.user_member}")
    IPage<AccountUser> getMemberLevel(IPage<AccountUser> page, @Param("map2") Map map2);


}
